//
//  HMMainTabbarVC.swift
//  swift一遍敲
//
//  Created by 刘耀宗 on 16/4/19.
//  Copyright © 2016年 刘耀宗. All rights reserved.
//

import UIKit

class HMMainTabbarVC: UITabBarController {
    override func viewDidLoad() {
        super.viewDidLoad()
        
    let tabbar = HMTabbar()
        tabbar.composeClosure = {
       print("点击了加号")
        }
     
        //背景颜色
         addChildVC(HMHomeVC(), title: "首页", imageName: "tabbar_home")
        addChildVC(HMDiscoverVC(), title: "发现", imageName: "tabbar_discover")
       
        addChildVC(HMMessageVC(), title: "消息", imageName: "tabbar_message_center")
      
        addChildVC(HMProfielVC(), title: "我", imageName: "tabbar_profile")
         self.setValue(tabbar, forKey: "tabBar")
        
    }
    //快速添加
    private func addChildVC(vc: UITableViewController, title: String, imageName: String )
    {
       
        vc.title = title
        vc.tabBarItem.image = UIImage(named: imageName)
       

        let navc = UINavigationController.init(rootViewController: vc)
         self.navigationController?.presentViewController(navc, animated: true, completion: nil)
        //添加子控制器
        self.addChildViewController(navc)
     
    }

}
